# -*- utf-8 -*-
sz = int(input())
szcp = sz
inputData = []
item_size = []

while sz:
    sz -= 1
    s = int(input())
    item_size.append(s)
    inputData.append([])
    while s:
        s -= 1
        inputData[len(inputData) - 1].append([int(i) for i in input().split(' ')])
max_run = szcp * sum(item_size)
ng = 0
print(inputData)
# 删除可以忽略的坐标留下消不掉的
while max_run:
    cp = inputData
    for it, item in enumerate(cp):
        if len(item) == 0:
            continue
        # 移除自身
        cp_item = item
        check_xy = 0
        for ie, ids in enumerate(item):
            # 同一个坐标
            if item[check_xy] == ids and ie != check_xy:
                del cp_item[ie]
                continue
            # 范围爆炸
            if item[check_xy][0] - 1 == ids[0] \
                    or item[check_xy][0] + 1 == ids[0] \
                    or item[check_xy][1] - 1 == ids[1] \
                    or item[check_xy][1] + 1 == ids[1]:
                del cp_item[ie]
                continue

        inputData[it] = cp_item

print(inputData)
